package com.lanswon.qzsmk.controller.inventoryManageController;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.http.client.HttpResponseException;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import ch.qos.logback.classic.Logger;

import com.lanswon.qzsmk.exception.ApplicationException;
import com.lanswon.qzsmk.exception.InventoryException;
import com.lanswon.qzsmk.exception.SystemException;
import com.lanswon.qzsmk.annotation.SystemControllerLog;
import com.lanswon.qzsmk.base.DwzPage;
import com.lanswon.qzsmk.base.HttpContants;
import com.lanswon.qzsmk.dao.StockSumMapper;
import com.lanswon.qzsmk.dao.StorageRegMapper;
import com.lanswon.qzsmk.model.ActiveUser;
import com.lanswon.qzsmk.model.CardControl;
import com.lanswon.qzsmk.model.CardData;
import com.lanswon.qzsmk.model.CardProdunctDefinition;
import com.lanswon.qzsmk.model.CardTask;
import com.lanswon.qzsmk.model.CardType;
import com.lanswon.qzsmk.model.CooperationCompany;
import com.lanswon.qzsmk.model.StorageModeDefinition;
import com.lanswon.qzsmk.model.StorageReg;
import com.lanswon.qzsmk.service.systemManageService.CardParameterManagementService;
import com.lanswon.qzsmk.service.systemManageService.InventoryManagementService;
import com.lanswon.qzsmk.service.systemManageService.ParamManageService;
import com.lanswon.qzsmk.vo.ApplyBatchInfo;
import com.lanswon.qzsmk.vo.ResponseCardFileVo;
import com.lanswon.qzsmk.vo.ResultObject;
import com.lanswon.qzsmk.vo.ResultVo;
import com.lanswon.qzsmk.vo.StorageRegRecVo;

/**
 * 库存管理Controller类
 * 
 * @author Guyw
 * @param
 *
 */
@Controller
@RequestMapping(value = "/inventorymanagement")
public class InventoryManagementController {

	private final static Logger logger = (Logger) LoggerFactory.getLogger(InventoryManagementController.class);

	@Autowired
	InventoryManagementService ims;

	@Autowired
	StorageRegMapper srm;

	@Autowired
	StockSumMapper ssm;

	@Autowired
	CardParameterManagementService cpm;
	
	@Autowired
	ParamManageService pm;

	

	/**
	 * 子模块：网点接收配送并入库 
	 * 获取柜员和网点编号
	 * @return
	 */
	@RequestMapping(value = "/getUserAndBanch", method = RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "获取柜员和网点编号")
	public Map<String, Object> getUserAndBanch() {
		Map<String, Object> map = new HashMap<>();
		ActiveUser activeUser = (ActiveUser) SecurityUtils.getSubject().getSession().getAttribute("activeUser");
		map.put("activeUser", activeUser);
		logger.debug("map===>"+map);
		return map;
	}
	
	@RequestMapping(value="/getStorageModeInfo",method=RequestMethod.GET)
	@ResponseBody
	@SystemControllerLog(description = "查询出入库定义信息")
	public Map<String, List<StorageModeDefinition>>getStorageModeInfo(HttpServletRequest request) throws Exception{
		
		String storageModeType = request.getParameter("storageModeType");
		logger.debug("storageModeType==>"+storageModeType);
		List<StorageModeDefinition> StorageModeDefinitionList = ims.queryStorageModeDefinition(storageModeType);
		

		Map<String, List<StorageModeDefinition>> map = new HashMap<String,List<StorageModeDefinition>>();

		map.put("storageModeInfo", StorageModeDefinitionList);

		return map;
	}
	

	/**
	 * 跳转出库撤销登记页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "/queryOutgoRevoctionReg", method = RequestMethod.POST)
	@SystemControllerLog(description = "跳转出库撤销登记页面")
	public String queryOutgoRevoctionReg(HttpServletRequest request) {
		return "OutgoingRevocationReg";
	}


	
	
	
	/**
	 * 显示读卡得到的信息
	 * 
	 * @return
	 */
	@RequestMapping(value = "/queryCardControl", method = RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "显示读卡得到的信息")
	public Map<String, Object> queryCardControl(HttpServletRequest request, String citizenCardNo) {
		Map<String, Object> map = new HashMap<>();
		List<CardData> lists = (List<CardData>) request.getSession().getAttribute("list");
		//通过卡号，查询卡产品名称和卡代码
		CardData cardDataInfo = ims.queryCardDataByCitizenNo(citizenCardNo);
		if(cardDataInfo!=null){
			if (lists == null) {
				List<CardData> list = new ArrayList<CardData>();		
				list.add(cardDataInfo);
				request.getSession().setAttribute("list", list);
				map.put("list", list);
			} else{
				lists.add(cardDataInfo);
				request.getSession().removeAttribute("list");
				request.getSession().setAttribute("list", lists);
				map.put("list", lists);
			}
		}
		else{
			map.put("flag", "false");
		}
		logger.debug("lists===>"+map);
		return map;
	}
	
	

	
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：设置任务号
	 * @return 
	 */
	@RequestMapping(value="/setTaskNo",method=RequestMethod.GET)
	@ResponseBody
	@SystemControllerLog(description = "设置任务号")
	public Map<String,Object> setTaskNo(HttpServletRequest request){
		Map<String,Object> rmap = new HashMap<String,Object>();
		String taskNo = (String)request.getSession().getAttribute("taskNoExists");
		request.getSession().removeAttribute("taskNoExists");
		if("".equals(taskNo)||taskNo==null){
			Date date = new Date();
			//设置任务号  年月日时分秒
			//20180821鱼洲杰修改
			SimpleDateFormat formatter=new SimpleDateFormat("yyMMdd"); 
			taskNo = formatter.format(date);
			int a=(int)((Math.random()*9+1)*1000);
			taskNo=taskNo+String.valueOf(a);
		}
		
		rmap.put("taskNo", taskNo);
		//参数键值对
		return rmap;
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：加载配送任务清单的信息（临时）
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/loadDistributeInfo",method=RequestMethod.GET)
	@ResponseBody
	@SystemControllerLog(description = "加载配送任务清单的信息")
	public Map<String, Object> loadDistributeInfo(HttpServletRequest request){
		Map<String, Object> map = new HashMap<String,Object>();
		//获取文件名称
		String filename = request.getParameter("fileName");
		logger.debug("文件名称是=====>"+filename);
		map = ims.queryDistributeInfo(filename);
		logger.debug("返回的map==>"+map);
		return map;
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：跳转到查询废卡的画面
	 * @return 
	 */
	@RequestMapping(value="/queryRejectCardInfo",method=RequestMethod.GET)
	@SystemControllerLog(description = "跳转到查询废卡的画面")
	public String queryRejectCardInfo(HttpServletRequest request){
		String params = request.getParameter("param");
		logger.debug("前画面传过来的参数==>"+params);
		String cardControlIdList = request.getParameter("list");
		logger.debug("前画面传过来的卡控制ID是==>"+cardControlIdList);
		request.getSession().removeAttribute("params");
		request.getSession().setAttribute("params", params);
		request.getSession().removeAttribute("list");
		request.getSession().setAttribute("list", cardControlIdList);
		
		return "ToCreateDistribution";
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：查询废卡信息
	 * @param request
	 * @return rmap 废卡信息map
	 */
	@RequestMapping(value="/queryDIstributeCardInfo",method=RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "查询废卡信息")
	public Map<String,Object> queryDIstributeCardInfo(HttpServletRequest request){
		Map<String,Object> rmap = new HashMap<String,Object>();
		String citizenCardNo = request.getParameter("citizenCardNo");
		String cardCode = request.getParameter("CardCode");
		String fromDate = request.getParameter("fromDate");
		String toDate = request.getParameter("toDate");
		String branchNo = request.getParameter("branchNo");
		String cardControlIdList = request.getParameter("cardControlIdList");
		logger.debug("查询画面穿过来的值citizenCardNo==>"+citizenCardNo);
		logger.debug("查询画面穿过来的值CardCode==>"+cardCode);
		logger.debug("查询画面穿过来的值fromDate==>"+fromDate);
		logger.debug("查询画面穿过来的值toDate==>"+toDate);
		logger.debug("查询画面穿过来的值branchNo==>"+branchNo);
		logger.debug("查询画面穿过来的值卡控制ID==>"+cardControlIdList);
		//参数键值对
		Map<String,String> paramMap = new HashMap<String,String>();
		paramMap.put("citizenCardNo", citizenCardNo);
		paramMap.put("cardCode", cardCode);
		paramMap.put("fromDate", fromDate);
		paramMap.put("toDate", toDate);
		paramMap.put("branchNo", branchNo);
		paramMap.put("cardControlIdList", cardControlIdList);
		//读出废卡信息
		rmap = ims.queryDistributeCardInfoByReject(paramMap);
		return rmap;
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：将选中的废卡信息添加到配送任务
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/createDistributeTaskFile",method=RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "将选中的废卡信息添加到配送任务")
	public Map<String,Object> createDistributeTaskFile(HttpServletRequest request,String[] distributionTasks){
		Map<String,Object> rmap = new HashMap<String,Object>();
		//获取页面选中的值
		String checkedItems = null;
		for(int m=0;m<distributionTasks.length;m++){
			try {
			if(m==0){
			    	checkedItems = URLDecoder.decode(distributionTasks[m], "utf-8");
					
			}else{
					checkedItems = checkedItems +"$"+ URLDecoder.decode(distributionTasks[m],"utf-8");
			}
			
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
				rmap.put("statusCode", "300");
				rmap.put("message", "转码异常");
				return rmap;
			}
		}

		String branchNo = request.getParameter("branchNoByCreateDis");
		String taskNo = request.getParameter("taskNoByCreateDis");
		String empNo = request.getParameter("empNoByCreateDis");
		
		logger.debug("前画面选中的项目==>"+checkedItems);
		logger.debug("前画面的网点号==>"+branchNo);
		logger.debug("前画面的任务号==>"+taskNo);
		logger.debug("前画面的员工号==>"+empNo);
		//后台处理生成文件
		Map<String,String> fileNameMap = ims.createDistributeTaskFile(checkedItems,branchNo,taskNo,empNo);	
		
		rmap.put("statusCode", "200");
		rmap.put("navTabId", "cardDistribution");
		rmap.put("callbackType", "closeCurrent");
		//将画面上的任务号传递到下个画面
		rmap.put("taskNo", taskNo);
		rmap.put("method", "GET");
		rmap.put("forwardUrl", "inventorymanagement/distributionRejectTask");
		return rmap;
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：将前画面的信息传入废卡查询画面，不重复查询
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/parseTaskParams",method=RequestMethod.GET)
	@ResponseBody
	@SystemControllerLog(description = "将前画面的信息传入废卡查询画面")	
	public Map<String, Object> parseTaskParams(HttpServletRequest request){
		//map是装有文件中的行数据清单
		Map<String, Object> map = new HashMap<String,Object>();
		//要删除的选项中的卡号，卡号是唯一的
		String params = (String)request.getSession().getAttribute("params");
		String list = (String)request.getSession().getAttribute("list");
		request.getSession().removeAttribute("list");
		request.getSession().removeAttribute("params");
		String[] paramArray = params.split("#");
		map.put("taskNo", paramArray[0]);
		map.put("branchNo", paramArray[1]);
		map.put("empNo", paramArray[2]);
		map.put("controlIdLIst", list);
		return map;
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：删除项目，重新刷新配送任务
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/deleteDistributeItem",method=RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "删除项目，重新刷新配送任务")
	public Map<String, Object> deleteDistributeItem(HttpServletRequest request){
		//map是装有文件中的行数据清单
		Map<String, Object> map = new HashMap<String,Object>();
		//要删除的选项中的卡号，卡号是唯一的
		String deleteItems = (String)request.getParameter("citizenCardNo");
		String controlID = (String)request.getParameter("cardControlId");
		String fileName = (String)request.getParameter("fileName");
		String empNo = (String)request.getParameter("empNo");
		logger.debug("要删除的选项==>"+deleteItems);
		logger.debug("要删除的卡控制号==>"+controlID);
		logger.debug("要删除的文件名称是==>"+fileName);
		logger.debug("员工编号是==>"+empNo);
		//删除txt中对应的数据行
		map = ims.deleteItems(deleteItems,fileName,controlID,empNo);
		return map;
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：跳转到配送任务登记页面
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/toTaskDetailInfo",method=RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "跳转到配送任务登记画面")
	public Map<String, Object> toTaskDetailInfo(HttpServletRequest request,String[] distributeItem){
		//map是装有文件中的行数据清单
		Map<String, Object> map = new HashMap<String,Object>();
		//获取网点号和任务号组成的文件名称
		String branchNo = request.getParameter("branchNo");
		String distributeNo = request.getParameter("ditributeTaskNo");
		String fileName = branchNo+distributeNo+".txt";
		String empNo = request.getParameter("empNo");
		logger.debug("文件名称==>"+fileName);
		//itemList 卡号和产品名称
		request.getSession().removeAttribute("fileNameByReg");
		request.getSession().setAttribute("fileNameByReg", fileName);
		request.getSession().removeAttribute("empNo");
		request.getSession().setAttribute("empNo", empNo);
		
		map.put("statusCode", "200");
		map.put("callbackType", "forward");
		map.put("forwardUrl", "inventorymanagement/toDistributeRejReg");
		return map;
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 转发到废卡配送登记画面
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/toDistributeRejReg",method=RequestMethod.POST)
	@SystemControllerLog(description = "转发到废卡配送登记画面")
	public String toDistributeRejReg(HttpServletRequest request){
		return "DistributeTaskReg";
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：加载配送详细信息
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/loadDistributeInfoByReg",method=RequestMethod.GET)
	@ResponseBody
	@SystemControllerLog(description = "加载配送详细信息")
	public Map<String, Object> loadDistributeInfoByReg(HttpServletRequest request){
		Map<String, Object> map = new HashMap<String,Object>();
		//出入库流水号，配送日期，配送任务号
		Map<String,Object> infoMap = ims.getDistributeTaskInfo();
		
		String fileName = (String)request.getSession().getAttribute("fileNameByReg");
		String empNo = (String)request.getSession().getAttribute("empNo");
		request.getSession().removeAttribute("fileNameByReg");
		request.getSession().removeAttribute("empNo");
		String taskNo = fileName.substring(8,18);//20180821鱼洲杰修改以下
		String branchNo = fileName.substring(0, 8);
		ActiveUser activeUser = (ActiveUser) SecurityUtils.getSubject().getSession().getAttribute("activeUser");
		map = ims.queryDistributeInfo(fileName);
		map.put("empNo",empNo);
		map.put("taskNo",taskNo);
		map.put("branchNo",branchNo);
//		map.put("storageNo", infoMap.get("storageNo"));
		map.put("curDate", infoMap.get("curDate"));
		map.put("activeUser", activeUser);
		logger.debug("返回的map==>"+map);
		return map;
	}
	
	/**
	 * 子模块：网点废卡配送并出库
	 * 功能：配送任务出库处理
	 * @param request
	 * @return
	 * @throws ApplicationException 
	 * @throws InventoryException 
	 */
	@RequestMapping(value="/submitDistributeInfo",method=RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "配送任务出库处理")
	public Map<String,Object> submitDistributeInfo(HttpServletRequest request) throws ApplicationException, InventoryException{
		Map<String, Object> map = new HashMap<>();
		//获取画面传过来的所有值
		String serializeFormByDistribute = request.getParameter("serializeFormByDistribute");
		logger.debug("配送登记页面传送过来的值==>"+serializeFormByDistribute.toString());
		
		// 打印参数的组装map
		Map<String, Object> resultMap = null;

		resultMap = ims.submitDistributeTask(serializeFormByDistribute);
		//生成PDF
		ims.createStoragePDF(resultMap);
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("applyType", resultMap.get("credential_type"));
		map.put("storageNo", resultMap.get("storageNo"));
		map.put("max", "true");
		map.put("title", resultMap.get("title"));
		map.put("rel", "distributeRjectTask");
		map.put("statusCode", "200");
		map.put("message", "操作成功");
		map.put("param", paramMap);
		map.put("url", "printCredentials/toStoragePdfView");
		return map;
	}	
	
	
	/**
	 * 子模块：网点接收配送并入库 
	 * 网点接收页面加载
	 * @return
	 */

	
	//----------------------------------------------------------------------------------------------
	
	/**
	 * 子模块：中心库接废卡上缴入库 
	 * 查询上缴的废卡信息
	 * @return
	 */
	@RequestMapping(value = "/queryRejectCardReceiving", method = { RequestMethod.POST, RequestMethod.GET })
	@SystemControllerLog(description = "查询上缴的废卡信息")
	public String queryRejectCardReceiving(HttpServletRequest request) {
		return "RejectCardReceiving";
	}
	
	/**
	 * 子模块：网点接收配送并入库 
	 * 网点接收页面加载
	 * @return
	 */
	@RequestMapping(value = "/getRejectCardReceiving", method = RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "网点接收页面加载")
	public Map<String, Object> getRejectCardReceiving(HttpServletRequest request, Integer pageNum, Integer numPerPage) {
		if (pageNum == null && numPerPage == null) {
			pageNum = 1;
			numPerPage = 10;
		}
		// 接收前画面穿过来数据
		String distributeTaskNo = request.getParameter("rejectDistributeTaskNoByReceiving");
		// 装有画面信息的map
		Map<String, String> map = new HashMap<String, String>();
		map.put("distributeTaskNo", distributeTaskNo);
		DwzPage<Map<String,String>> dpList = ims.getRejectCardReceiving(map, pageNum, numPerPage);
		Map<String, Object> rMap = new HashMap<>();
		rMap.put("list", dpList);
		rMap.put("distributeNo", distributeTaskNo);
		return rMap;
	}
	
	/**
	 * 子模块：中心库接收废卡上缴入库
	 * 提交信息
	 * @param request
	 * @return
	 * @throws InventoryException 
	 * @throws ApplicationException 
	 */
	@RequestMapping(value = "/rejectCardReceivingRegister", method = RequestMethod.POST)
	@ResponseBody
	@SystemControllerLog(description = "提交信息")
	public Map<String, Object> rejectCardReceivingRegister(String[] rejectCardReceivingtasked) throws InventoryException {
		Map<String, Object> map = new HashMap<>();
		// 前画面组装成的参数
		String[] paramString = rejectCardReceivingtasked;
		// 打印参数的组装map
		Map<String, Object> resultMap = null;

		resultMap = ims.RejectCardReceivingRegist(paramString);
		logger.debug("resultMap===>" + resultMap);

		// 生成PDF
		ims.createStoragePDF(resultMap);

		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("applyType", resultMap.get("credential_type"));
		
		map.put("storageNo", resultMap.get("storageNo"));
		map.put("max", "true");
		map.put("title", resultMap.get("title"));
		map.put("rel", "receiveTask");
		map.put("statusCode", "200");
		map.put("message", "操作成功");
		map.put("param", paramMap);
		map.put("url", "printCredentials/toStoragePdfView");
		return map;
	}
			
	/**
	 * 子模块：所有入库清单的预览
	 * 功能：弹出所选入库单号的清单预览
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/getStorageFile", method = RequestMethod.GET)
	@SystemControllerLog(description = "弹出所选入库单号的清单预览")
	public String getStorageFile(HttpServletRequest request){
		String credential_type = request.getParameter("credential_type");
		String credentialNo = request.getParameter("credentialNo");
		String ipAddress = request.getParameter("ipAddress");
		logger.debug("credential_type===>"+credential_type);
		logger.debug("credentialNo===>"+credentialNo);
		logger.debug("ipAddress===>"+ipAddress);
		if(!"".equals(credential_type)&&credential_type!=null){
			request.getSession().removeAttribute("credential_type");
			request.getSession().setAttribute("credential_type", credential_type);
		}
		if(!"".equals(credentialNo)&&credentialNo!=null){
			request.getSession().removeAttribute("credentialNo");
			request.getSession().setAttribute("credentialNo", credentialNo);
		}
		if(!"".equals(ipAddress)&&ipAddress!=null){
			request.getSession().removeAttribute("ipAddress");
			request.getSession().setAttribute("ipAddress", ipAddress);
		}
		return "StoragePdfViewPage";
	}
	
	
	//-----测试----------------------------------------------------------------------------------
	@RequestMapping(value = "/testHGL", method = { RequestMethod.POST, RequestMethod.GET })
	public String testHGL(HttpServletRequest request) {
		logger.info("testHGL########start");
		logger.info("testHGL########end");
		return "InventoryQueryTest";
	}
	
	
	
	
	
	
	
	
	@RequestMapping(value="/getCardInfo",method=RequestMethod.GET)
	@ResponseBody
	public Map<String, Object>getCardInfo(HttpServletRequest request) throws Exception{
		logger.info("getCardInfo########start()");
		List<CardProdunctDefinition> cdProDefinitions=null;
		ResultVo resultVo=pm.queryAllCardProdunctDefinition();//卡产品集合
		if(resultVo.getResultStatus().getCode()==HttpContants.RETURN_SUCCESS){
			cdProDefinitions=(List<CardProdunctDefinition>)((ResultObject)resultVo.getServiceObject()).getItems();
		}
		/*获取卡类型：记名，不记名，标准*/
		List<CardType> cardTypeList = cpm.queryAllCardType();
		Map<String, Object> map=new HashMap<>();
	/*	map.put("cardpCode", workMap.get("cardpCode"));*/
		map.put("cdProDefinitions", cdProDefinitions);
		/*map.put("cardTypeCode", workMap.get("cardTypeCode"));*/
		map.put("cardTypes", cardTypeList);
		/*map.put("currentPage", workMap.get("currentPage"));
		map.put("numPerPage", workMap.get("numPerPage"));
		map.put("pageCount", workMap.get("pageCount"));*/
		logger.info("getCardInfo########end()");
		return map;
	}
	
	@RequestMapping(value="/queryCardInfoByCardNo",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> queryCardInfoByCardNo(HttpServletRequest request) throws Exception{
		Map<String, Object> map = new HashMap<>();
		map = ims.queryCardInfoByCitizenCardNo(request);
		return map;
	}
	
	@RequestMapping(value="/getMakeCardCompany",method=RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getMakeCardCompany() throws Exception{
		Map<String, Object> map = new HashMap<>();
		List<CooperationCompany> companyList= ims.queryCooperationCompanyByType("1");
		map.put("companies", companyList);
		logger.debug("map==>"+map);
		return map;
	}
	
	@RequestMapping(value="/createTableList",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> createTableList(HttpServletRequest request) throws Exception{
		Map<String,String> rmap = new HashMap<String,String>();
		rmap = ims.createTableListPDF(request);
		
		Map<String, Object> map = new HashMap<String, Object>();
		Map<String,Object> pramMap = new HashMap<String,Object>();
		pramMap.put("applyType", rmap.get("credential_type"));
		map.put("ipAddress", rmap.get("ipAddress"));
		map.put("storageNo", rmap.get("storageNo"));
		map.put("param", pramMap);
		map.put("width", "600");
		map.put("height", "500");
		map.put("title", rmap.get("title"));
		map.put("rel", "inventorySumPrint");
		map.put("statusCode","200");
		map.put("closeTabFlag", true);
		map.put("url", "printCredentials/toStoragePdfView");
		return map;
	}
	
	@RequestMapping(value="/checkEmp",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Boolean> checkEmp(HttpServletRequest request) throws Exception{
		Map<String,Boolean> rmap = new HashMap<String,Boolean>();
		rmap = ims.checkEmpAndBranch(request);
		return rmap;
	}
	
	
	
}
